package com.gaoding.shared.dict.sdk.service;

import com.gaoding.shared.dict.sdk.cache.DefaultCacheManage;
import com.gaoding.shared.dict.sdk.context.DictSdkContext;

/**
 * @Description:
 * @Author: 西格 xige@gaoding.com
 * @date 2021-02-04 16:31
 */
public class DictQuery {
    private final static String DEFAULT_LOCAL = "zh-cn";

    /**
     * 默认读取application.properties里spring.application.name配置当作项目名称
     * 默认中文
     */
    public static String getValue(String key) {
        return getValue(key, DEFAULT_LOCAL);
    }

    /**
     * 目前不传local默认中文
     */
    public static String getValue(String key, String local) {
        return getValue(DictSdkContext.INSTANCE.getAllServiceCode().get(0), key, local);
    }

    /**
     * 如果需要读取别的项目配置，则在需要在application.properties里dict.sdk.multi-application-names配置别的项目用,隔开
     */
    public static String getValue(String serviceCode, String key, String local) {
        return DefaultCacheManage.getValue(serviceCode, key, local);
    }

    /**
     * 获取服务编码无关的key
     */
    public static String getWithoutServiceCode(String key) {
        return DefaultCacheManage.getWithoutServiceCode(key, DEFAULT_LOCAL);
    }
}
